function time(options){
  const date = new Date();
  const num = date.getTime();
  const n = options.time;
  const cha = num - n;
  if(3600000 > cha){
    return Math.floor(cha/60000)+"分钟前";
  }else if(num%86400000 >= cha){
    return Math.floor(cha/3600000)+"小时前";
  }else if(num%86400000+86400000 >= cha){
    return "昨天";
  }else{
    const dates = new Date(n);
    const year = dates.getFullYear();
    const month =dates.getMonth()+1;
    const day = dates.getDate();
    return [year,month,day].map((n)=>{
      n=n.toString();
      return n[1] ? n : '0' + n;
    }).join('-');
  }
}

module.exports = {
  time
}